package cn.wsalix.constant;

public class WxGlobal {
	public final static String MENU_CREATE_URL = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=%s";
	// http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html
	// 网页授权获取用户基本信息
	public final static String WX_CODE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect";
	public static final String ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
	// 支付宝公钥
	public static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
	public static final String USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN";
	public static final String OAUTH2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";

	public static final String APP_USER_INFO = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s";
	public static final String APP_TO_ORDER = "https://api.mch.weixin.qq.com/pay/unifiedorder";
	public static final String AUTH_REDIRECT_URI = "http://%s%s/wx/%s/%s.do";// host,young,reg,wxconfid_Id

	public final static String doGetWxCode(String appId, String redirectUri,
			String scope, String state) {
		return String.format(WX_CODE_URL, appId, redirectUri, scope, state);
	}

	public final static String doGetMenuCreate(String accessToken) {
		return String.format(MENU_CREATE_URL, accessToken);
	}

	public final static String doGetAccessToken(String appId, String appSecret) {
		return String.format(ACCESS_TOKEN_URL, appId, appSecret);
	}

	public final static String doGetUserInfo(String accessToken, String openId) {
		return String.format(USER_INFO, accessToken, openId);
	}

	public final static String doGetAccessTokenByCode(String code,
			String appId, String appSecret) {
		return String.format(ACCESS_TOKEN, appId, appSecret, code);
	}

	public final static String doGetAppUserInfo(String accessToken,
			String openId) {
		return String.format(APP_USER_INFO, accessToken, openId);
	}

	public final static String doGetAppToOrder() {
		return APP_TO_ORDER;
	}

}
